home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-07-05 | 57.6 KB | 2,282 lines |
-
- Article 50 of comp.sources.games:
- Path: ncrcce!rd1632!ncrlnk!ncrcae!ece-csc!mcnc!seismo!rochester!cornell!uw-beaver!tektronix!tekgen!tekred!games-request
- From: games-request@tekred.TEK.COM
- Newsgroups: comp.sources.games
- Subject: v01i076: xtrek - multiplayer space war for X-windows, Part04/06
- Message-ID: <1369@tekred.TEK.COM>
- Date: 2 Jul 87 20:54:13 GMT
- Sender: billr@tekred.TEK.COM
- Lines: 2267
- Approved: billr@tekred.TEK.COM
-
- Submitted by: Chris Guthrie <chris%ic.Berkeley.EDU@ucbvax.berkeley.edu>
- Comp.sources.games: Volume 1, Issue 76
- Archive-name: xtrek/Part04
-
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 6)."
- # Contents: Makefile inform.c main.c pstats.c sintab.c smessage.c
- # stats.c struct.h war.c
- # Wrapped by billr@tekred on Thu Jul 2 10:26:32 1987
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f Makefile -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"Makefile\"
- else
- echo shar: Extracting \"Makefile\" \(9193 characters\)
- sed "s/^X//" >Makefile <<'END_OF_Makefile'
- XDESTDIR = /usr/games
- XXTREKDIR = /usr/games/lib/xtrek
- XXTREKOWNER = daemon
- X
- XR_OBJS = colors.o \
- X coup.o \
- X data.o \
- X death.o \
- X detonate.o \
- X dmessage.o \
- X enter.o \
- X getship.o \
- X inform.o \
- X input.o \
- X interface.o \
- X main.o \
- X newwin.o \
- X orbit.o \
- X phaser.o \
- X planetlist.o \
- X playerlist.o \
- X pstats.o \
- X redraw.o \
- X sintab.o \
- X smessage.o \
- X startdaemon.o \
- X stats.o \
- X torp.o \
- X util.o \
- X war.o \
- X warning.o
- X
- XR_FILES = colors.c \
- X coup.c \
- X data.c \
- X death.c \
- X detonate.c \
- X dmessage.c \
- X enter.c \
- X getship.c \
- X inform.c \
- X input.c \
- X interface.c \
- X main.c \
- X newwin.c \
- X orbit.c \
- X phaser.c \
- X planetlist.c \
- X playerlist.c \
- X pstats.c \
- X redraw.c \
- X sintab.c \
- X smessage.c \
- X startdaemon.c \
- X stats.c \
- X torp.c \
- X util.c \
- X war.c \
- X warning.c
- X
- XD_OBJS = daemon.o \
- X sintab.o \
- X data.o
- X# random.o -- put this back if you have a better rand()
- X
- Xr_OBJS = data.o \
- X detonate.o \
- X enter.o \
- X getship.o \
- X interface.o \
- X phaser.o \
- X robot.o \
- X rmove.o \
- X sintab.o \
- X startdaemon.o \
- X torp.o \
- X util.o
- X
- XLIBS = -lX -lm
- X
- XCFLAGS = -O
- X
- Xall: xtrek daemon robot
- X
- Xxtrek: $(R_OBJS)
- X cc $(CFLAGS) -o xtrek $(R_OBJS) $(LIBS)
- X chmod 4711 xtrek
- X
- Xdaemon: $(D_OBJS)
- X cc $(CFLAGS) -o daemon $(D_OBJS) -lm
- X chmod 4711 daemon
- X
- Xrobot: $(r_OBJS)
- X cc $(CFLAGS) -o robot $(r_OBJS) $(LIBS)
- X chmod 4711 robot
- X
- Xinstall: xtrek daemon
- X -mv $(DESTDIR)/xtrek $(DESTDIR)/xtrek.old
- X cp xtrek $(DESTDIR)
- X chmod 4711 $(DESTDIR)/xtrek
- X chown $(XTREKOWNER) $(DESTDIR)/xtrek
- X -mv $(XTREKDIR)/daemon $(XTREKDIR)/daemon.old
- X cp daemon $(XTREKDIR)
- X chmod 4711 $(XTREKDIR)/daemon
- X chown $(XTREKOWNER) $(XTREKDIR)/daemon
- X -mv $(XTREKDIR)/robot $(XTREKDIR)/robot.old
- X cp robot $(XTREKDIR)
- X chmod 4711 $(XTREKDIR)/robot
- X chown $(XTREKOWNER) $(XTREKDIR)/robot
- X touch $(XTREKDIR)/.planets $(XTREKDIR)/.motd $(XTREKDIR)/.scores
- X chown $(XTREKOWNER) $(XTREKDIR)/.planets $(XTREKDIR)/.motd \
- X $(XTREKDIR)/.scores
- X chmod 644 $(XTREKDIR)/.scores $(XTREKDIR)/.motd
- X chmod 600 $(XTREKDIR)/.planets
- X
- Xlint:
- X lint -abchp ${R_FILES}
- X
- Xclean:
- X -rm -f *.o core a.out xtrek daemon robot
- X
- X###
- Xcolors.o: /usr/include/stdio.h /usr/include/X/Xlib.h \
- X /usr/include/X/mit-copyright.h /usr/include/sys/types.h \
- X /usr/include/X/X.h /usr/include/strings.h data.h
- Xcoup.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h defs.h struct.h data.h
- Xdaemon.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h /usr/include/sys/time.h \
- X /usr/include/sys/file.h /usr/include/sys/wait.h \
- X /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h \
- X /usr/include/sys/ttydev.h /usr/include/sgtty.h /usr/include/signal.h \
- X /usr/include/setjmp.h /usr/include/math.h defs.h struct.h data.h \
- X planets.h /usr/include/sys/resource.h
- Xdata.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h defs.h struct.h data.h
- Xdeath.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/signal.h /usr/include/setjmp.h /usr/include/sys/time.h \
- X defs.h struct.h data.h
- Xdetonate.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h defs.h struct.h data.h
- Xdmessage.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xenter.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h /usr/include/errno.h \
- X /usr/include/pwd.h /usr/include/strings.h /usr/include/ctype.h defs.h \
- X struct.h data.h
- Xgetship.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h defs.h struct.h data.h
- Xhose.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h /usr/include/sys/time.h \
- X /usr/include/sys/file.h /usr/include/sys/wait.h \
- X /usr/include/sys/ioctl.h /usr/include/sys/ttychars.h \
- X /usr/include/sys/ttydev.h /usr/include/sgtty.h /usr/include/signal.h \
- X /usr/include/setjmp.h /usr/include/math.h defs.h struct.h data.h \
- X planets.h
- Xinform.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xinput.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/sys/time.h /usr/include/signal.h \
- X /usr/include/errno.h defs.h struct.h data.h
- Xinterface.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xmain.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/time.h /usr/include/signal.h /usr/include/setjmp.h \
- X defs.h struct.h data.h
- Xnewwin.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h /usr/include/sys/time.h \
- X defs.h struct.h data.h bitmaps.h clock.bitmap
- Xorbit.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h defs.h struct.h data.h
- Xphaser.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xplanetlist.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X defs.h struct.h data.h
- Xplayerlist.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X defs.h struct.h data.h
- Xpstats.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/time.h /usr/include/sys/resource.h \
- X /usr/include/sys/file.h /usr/include/signal.h /usr/include/setjmp.h \
- X defs.h struct.h data.h
- Xredraw.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/signal.h /usr/include/math.h defs.h struct.h data.h \
- X bitmaps.h
- Xrmove.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/signal.h /usr/include/math.h defs.h struct.h data.h
- Xrobot.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/time.h /usr/include/signal.h /usr/include/setjmp.h \
- X defs.h struct.h data.h
- Xrotate.o: /usr/include/stdio.h /usr/include/math.h
- Xscores.o: /usr/include/stdio.h /usr/include/sys/types.h \
- X /usr/include/sys/file.h /usr/include/pwd.h defs.h struct.h
- Xsmessage.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h /usr/include/ctype.h defs.h \
- X struct.h data.h
- Xstartdaemon.o: /usr/include/stdio.h /usr/include/X/Xlib.h \
- X /usr/include/X/mit-copyright.h /usr/include/sys/types.h \
- X /usr/include/X/X.h defs.h struct.h data.h
- Xstats.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X defs.h struct.h data.h
- Xtorp.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/ipc.h /usr/include/sys/shm.h defs.h struct.h data.h
- Xutil.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xwar.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xwarning.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/math.h /usr/include/signal.h defs.h struct.h data.h
- Xxx.o: /usr/include/X/Xlib.h /usr/include/X/mit-copyright.h \
- X /usr/include/sys/types.h /usr/include/X/X.h /usr/include/stdio.h \
- X /usr/include/sys/time.h /usr/include/signal.h /usr/include/setjmp.h \
- X /usr/include/errno.h defs.h struct.h data.h
- END_OF_Makefile
- if test 9193 -ne `wc -c <Makefile`; then
- echo shar: \"Makefile\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f inform.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"inform.c\"
- else
- echo shar: Extracting \"inform.c\" \(5626 characters\)
- sed "s/^X//" >inform.c <<'END_OF_inform.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include <math.h>
- X#include <signal.h>
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- X#define WINSIDE 500
- X
- X/* Display information about the nearest objext to mouse */
- X
- X/*
- X** When the player asks for info, this routine finds the object
- X** nearest the mouse, either player or planet, and pop up a window
- X** with the desired information in it.
- X**
- X** We intentionally provide less information than is actually
- X** available. Keeps the fog of war up.
- X**
- X** There is a different sized window for each type player/planet
- X** and we take care to keep it from extending beyond the main
- X** window boundaries.
- X*/
- X
- Xinform(ww, x, y)
- XWindow ww;
- Xint x, y;
- X{
- X char buf[BUFSIZ];
- X int line = 0;
- X register struct player *j;
- X register struct planet *k;
- X int mx, my;
- X double dist;
- X Window subw;
- X struct obtype *gettarget(), *target;
- X static WindowInfo wi;
- X
- X infomapped = 1;
- X target = gettarget(ww, x, y, TARG_PLAYER|TARG_PLANET);
- X
- X if (wi.width == 0)
- X XQueryWindow(ww, &wi);
- X
- X XQueryMouse(ww, &mx, &my, &subw);
- X
- X if (target->o_type == PLAYERTYPE) {
- X /* Too close to the edge? */
- X if (mx + 23 * dfontinfo->width + 2 > wi.width)
- X mx = wi.width - 23 * dfontinfo->width - 2;
- X if (my + 7 * dfontinfo->height + 2 > wi.height)
- X my = wi.height - 7 * dfontinfo->height - 2;
- X
- X infow = XCreateWindow(ww, mx, my, 23 * dfontinfo->width,
- X 7 * dfontinfo->height, 2, foreTile, backTile);
- X XMapWindow(infow);
- X j = &players[target->o_num];
- X dist = hypot((double) (me->p_x - j->p_x),
- X (double) (me->p_y - j->p_y));
- X (void) sprintf(buf, "%s (%c%1x):", j->p_name, teamlet[j->p_team], j->p_no);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), shipFont(j), playerColor(j), backColor);
- X (void) sprintf(buf, "Login %-s", j->p_login);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X (void) sprintf(buf, "Display %-s", j->p_monitor);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X (void) sprintf(buf, "Speed %-d", j->p_speed);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X
- X /* Too much information. Let 'em wonder
- X (void) sprintf(buf, "Damage %-d", j->p_damage);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X (void) sprintf(buf, "Shields %-d", j->p_shield);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X */
- X
- X (void) sprintf(buf, "kills %-4.2f", j->p_kills);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X (void) sprintf(buf, "dist %-d", (int) dist);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, playerColor(j), backColor);
- X if (j->p_swar & me->p_team)
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, "WAR",
- X 3, dfont, playerColor(j), backColor);
- X else if (j->p_hostile & me->p_team)
- X XText(infow, dfontinfo->width, dfontinfo->height * line++,
- X "HOSTILE", 7, dfont, playerColor(j), backColor);
- X else
- X XText(infow, dfontinfo->width, dfontinfo->height * line++,
- X "PEACEFUL", 8, dfont, playerColor(j), backColor);
- X }
- X else { /* Planet */
- X /* Too close to the edge? */
- X if (mx + 20 * dfontinfo->width + 2 > wi.width)
- X mx = wi.width - 20 * dfontinfo->width - 2;
- X if (my + 3 * dfontinfo->height + 2 > wi.height)
- X my = wi.height - 3 * dfontinfo->height - 2;
- X
- X infow = XCreateWindow(ww, mx, my, 20 * dfontinfo->width,
- X 3 * dfontinfo->height, 2, foreTile, backTile);
- X XMapWindow(infow);
- X k = &planets[target->o_num];
- X dist = hypot((double) (me->p_x - k->pl_x),
- X (double) (me->p_y - k->pl_y));
- X if (k->pl_info & me->p_team) {
- X (void) sprintf(buf, "%s (%c)", k->pl_name, teamlet[k->pl_owner]);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), planetFont(k), planetColor(k), backColor);
- X (void) sprintf(buf, "Armies %d", k->pl_armies);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, planetColor(k), backColor);
- X (void) sprintf(buf, "%s %s %c%c%c%c",
- X (k->pl_flags & PLREPAIR ? "REPAIR" : " "),
- X (k->pl_flags & PLFUEL ? "FUEL" : " "),
- X (k->pl_info & FED ? 'F' : ' '),
- X (k->pl_info & ROM ? 'R' : ' '),
- X (k->pl_info & KLI ? 'K' : ' '),
- X (k->pl_info & ORI ? 'O' : ' '));
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, planetColor(k), backColor);
- X }
- X else {
- X (void) sprintf(buf, "%s", k->pl_name);
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, planetColor(k), backColor);
- X (void) sprintf(buf, "No other info");
- X XText(infow, dfontinfo->width, dfontinfo->height * line++, buf,
- X strlen(buf), dfont, planetColor(k), backColor);
- X }
- X XFlush();
- X }
- X}
- X
- X
- XdestroyInfo()
- X{
- X XDestroyWindow(infow);
- X infomapped = 0;
- X}
- END_OF_inform.c
- if test 5626 -ne `wc -c <inform.c`; then
- echo shar: \"inform.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f main.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"main.c\"
- else
- echo shar: Extracting \"main.c\" \(4437 characters\)
- sed "s/^X//" >main.c <<'END_OF_main.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include <string.h>
- X#include <sys/types.h>
- X#ifdef hpux
- X#include <time.h>
- X#else hpux
- X#include <sys/time.h>
- X#endif hpux
- X#include <signal.h>
- X#include <setjmp.h>
- X#include <pwd.h>
- X#ifndef hpux
- X#include <sys/wait.h>
- X#endif hpux
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- Xjmp_buf env;
- X
- Xmain(argc, argv)
- Xint argc;
- Xchar **argv;
- X{
- X int intrupt();
- X int team;
- X int pno;
- X char *host = NULL;
- X int usage = 0;
- X int err = 0;
- X char *name, *ptr, *rindex();
- X char buf[80];
- X struct passwd *pwent, *getpwuid();
- X int reaper();
- X
- X name = *argv++;
- X argc--;
- X if ((ptr = rindex(name, '/')) != NULL)
- X name = ptr + 1;
- X while (*argv) {
- X if (**argv == '-')
- X *++*argv;
- X else
- X break;
- X
- X argc--;
- X ptr = *argv++;
- X while (*ptr) {
- X switch (*ptr) {
- X case 'u': usage++; break;
- X case 'c':
- X if (*argv == 0) {
- X fprintf(stderr, "Missing required player number\n");
- X err++;
- X break;
- X }
- X pno = atoi(*argv);
- X argc--;
- X argv++;
- X if (pno < 0 || pno >= MAXPLAYER) {
- X fprintf(stderr, "Bad Player Number: %d\n", pno);
- X err++;
- X } else
- X copilot++;
- X break;
- X case 'w':
- X if (*argv == 0) {
- X fprintf(stderr, "Missing required player number\n");
- X err++;
- X break;
- X }
- X pno = atoi(*argv);
- X argc--;
- X argv++;
- X if (pno < 0 || pno >= MAXPLAYER) {
- X fprintf(stderr, "Bad Player Number: %d\n", pno);
- X err++;
- X } else
- X watch++;
- X break;
- X case 'd':
- X host = *argv;
- X argc--;
- X argv++;
- X break;
- X default:
- X fprintf(stderr, "%s: unknown option '%c'\n", name, *ptr);
- X err++;
- X break;
- X }
- X ptr++;
- X }
- X }
- X if (usage || err) {
- X printUsage(name);
- X exit(err);
- X }
- X if (watch && copilot) {
- X printf("%s: Cannot simultaneously use both watch and copilot.",
- X name);
- X exit(err);
- X }
- X /* compatability */
- X if (argc > 0)
- X host = argv[0];
- X srandom(getpid() * time((long *) 0));
- X /* this creates the necessary x windows for the game */
- X newwin(host, name);
- X /* this finds the shared memory information */
- X openmem();
- X /* map the windows */
- X mapAll();
- X if ((!copilot) && (!watch)) {
- X pno = findslot();
- X }
- X if (pno < 0) {
- X /* print some appropriate message */
- X exit(1);
- X }
- X me = &players[pno];
- X myship = &me->p_ship;
- X mystats = &me->p_stats;
- X lastm = mctl->mc_current;
- X signal(SIGINT, SIG_IGN);
- X signal(SIGQUIT, SIG_IGN);
- X (void) signal(SIGCLD, reaper);
- X
- X if ((!copilot) && (!watch)) {
- X me->p_team = ALLTEAM; /* Give full choice in startup window */
- X setjmp(env); /* Reentry point of game */
- X /* give the player the motd and find out which team he wants */
- X team = entrywindow();
- X if (team == -1) {
- X if (me != NULL)
- X savestats();
- X players[pno].p_status = PFREE;
- X exit(0);
- X }
- X time(&start_time); /* For stat gathering */
- X redrawall = 1;
- X enter(team, DisplayName(), pno);
- X XClear(w);
- X /*
- X for (i = 0; i < NSIG; i++) {
- X signal(i, SIG_IGN);
- X }
- X */
- X
- X if (showStats) /* Default showstats are on. */
- X statwin = openStats(me);
- X
- X me->p_status = PALIVE; /* Put player in game */
- X me->p_ghostbuster = 0;
- X }
- X else if (copilot) {
- X if (me->p_status != PALIVE)
- X exit(1);
- X if (!(me->p_flags & PFCOPILOT)) {
- X printf("%s is not allowing copilots\n", me->p_name);
- X exit(1);
- X }
- X if (showStats) /* Default showstats are on. */
- X statwin = openStats(me);
- X
- X if ((pwent = getpwuid(getuid())) == NULL)
- X sprintf(buf, "Unknown person joining as a copilot");
- X else
- X sprintf(buf, "%-8s joining as a copilot", pwent->pw_name);
- X
- X pmessage(buf, pno, MINDIV, "GOD->YOU");
- X }
- X /* else (watch) */
- X /* Get input until the player quits or dies */
- X input();
- X}
- X
- XprintUsage(prog)
- X char *prog;
- X{
- X printf("Usage: %s [-u] [-[cw] copilot-number] [-d display-name]\n",
- X prog);
- X}
- X
- Xreaper(sig)
- X{
- X#ifdef hpux
- X wait((int *) 0);
- X#else hpux
- X while (wait3((union wait *) 0, WNOHANG, (struct rusage *) 0) > 0)
- X ;
- X#endif hpux
- X}
- END_OF_main.c
- if test 4437 -ne `wc -c <main.c`; then
- echo shar: \"main.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f pstats.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"pstats.c\"
- else
- echo shar: Extracting \"pstats.c\" \(1924 characters\)
- sed "s/^X//" >pstats.c <<'END_OF_pstats.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include <sys/types.h>
- X#ifdef hpux
- X#include <time.h>
- X#else hpux
- X#include <sys/time.h>
- X#endif hpux
- X#include <sys/resource.h>
- X#include <sys/file.h>
- X#include <signal.h>
- X#include <setjmp.h>
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- Xstatic int fd;
- Xstatic struct stats old;
- Xstatic struct rusage buf;
- Xstatic long now;
- X
- Xsavestats()
- X{
- X fd = open(SCOREFILE, O_RDWR, 0777);
- X if (fd < 0)
- X return;
- X lseek(fd, getuid() * sizeof(struct stats), 0);
- X read(fd, &old, sizeof(struct stats));
- X
- X me->p_stats.st_kills += old.st_kills;
- X me->p_stats.st_losses += old.st_losses;
- X me->p_stats.st_entries += old.st_entries;
- X me->p_stats.st_conqs += old.st_conqs;
- X me->p_stats.st_coups += old.st_coups;
- X me->p_stats.st_torps += old.st_torps;
- X me->p_stats.st_phasers += old.st_phasers;
- X me->p_stats.st_armsbomb += old.st_armsbomb;
- X me->p_stats.st_armsship += old.st_armsship;
- X me->p_stats.st_planets += old.st_planets;
- X me->p_stats.st_genocides += old.st_genocides;
- X
- X time(&now);
- X me->p_stats.st_time = old.st_time + (now - start_time);
- X
- X getrusage(0, &buf);
- X me->p_stats.st_cpu = old.st_cpu + buf.ru_utime.tv_sec + buf.ru_stime.tv_sec;
- X
- X if (oldmax > old.st_maxkills)
- X mystats->st_maxkills = oldmax;
- X else
- X mystats->st_maxkills = old.st_maxkills;
- X
- X lseek(fd, getuid() * sizeof(struct stats), 0);
- X write(fd, mystats, sizeof(struct stats));
- X}
- END_OF_pstats.c
- if test 1924 -ne `wc -c <pstats.c`; then
- echo shar: \"pstats.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f sintab.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"sintab.c\"
- else
- echo shar: Extracting \"sintab.c\" \(6925 characters\)
- sed "s/^X//" >sintab.c <<'END_OF_sintab.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- Xdouble Sin[] = {
- X -1.0000,
- X -0.9997,
- X -0.9988,
- X -0.9973,
- X -0.9952,
- X -0.9925,
- X -0.9892,
- X -0.9853,
- X -0.9808,
- X -0.9757,
- X -0.9701,
- X -0.9638,
- X -0.9570,
- X -0.9496,
- X -0.9416,
- X -0.9330,
- X -0.9239,
- X -0.9143,
- X -0.9040,
- X -0.8933,
- X -0.8820,
- X -0.8701,
- X -0.8578,
- X -0.8449,
- X -0.8315,
- X -0.8176,
- X -0.8033,
- X -0.7884,
- X -0.7731,
- X -0.7573,
- X -0.7410,
- X -0.7243,
- X -0.7072,
- X -0.6896,
- X -0.6716,
- X -0.6533,
- X -0.6345,
- X -0.6153,
- X -0.5958,
- X -0.5759,
- X -0.5557,
- X -0.5351,
- X -0.5142,
- X -0.4930,
- X -0.4715,
- X -0.4497,
- X -0.4277,
- X -0.4054,
- X -0.3828,
- X -0.3600,
- X -0.3370,
- X -0.3138,
- X -0.2904,
- X -0.2668,
- X -0.2431,
- X -0.2192,
- X -0.1952,
- X -0.1711,
- X -0.1469,
- X -0.1225,
- X -0.0982,
- X -0.0737,
- X -0.0492,
- X -0.0247,
- X -0.0001,
- X 0.0244,
- X 0.0489,
- X 0.0734,
- X 0.0979,
- X 0.1223,
- X 0.1466,
- X 0.1708,
- X 0.1949,
- X 0.2190,
- X 0.2428,
- X 0.2666,
- X 0.2901,
- X 0.3135,
- X 0.3367,
- X 0.3598,
- X 0.3825,
- X 0.4051,
- X 0.4274,
- X 0.4495,
- X 0.4713,
- X 0.4928,
- X 0.5140,
- X 0.5349,
- X 0.5554,
- X 0.5757,
- X 0.5956,
- X 0.6151,
- X 0.6343,
- X 0.6531,
- X 0.6714,
- X 0.6894,
- X 0.7070,
- X 0.7241,
- X 0.7408,
- X 0.7571,
- X 0.7729,
- X 0.7882,
- X 0.8031,
- X 0.8175,
- X 0.8314,
- X 0.8448,
- X 0.8576,
- X 0.8700,
- X 0.8818,
- X 0.8931,
- X 0.9039,
- X 0.9141,
- X 0.9238,
- X 0.9329,
- X 0.9415,
- X 0.9495,
- X 0.9569,
- X 0.9637,
- X 0.9700,
- X 0.9757,
- X 0.9808,
- X 0.9852,
- X 0.9891,
- X 0.9925,
- X 0.9952,
- X 0.9973,
- X 0.9988,
- X 0.9997,
- X 1.0000,
- X 0.9997,
- X 0.9988,
- X 0.9973,
- X 0.9952,
- X 0.9925,
- X 0.9892,
- X 0.9853,
- X 0.9808,
- X 0.9757,
- X 0.9700,
- X 0.9638,
- X 0.9569,
- X 0.9495,
- X 0.9415,
- X 0.9330,
- X 0.9239,
- X 0.9142,
- X 0.9040,
- X 0.8932,
- X 0.8819,
- X 0.8701,
- X 0.8577,
- X 0.8449,
- X 0.8315,
- X 0.8176,
- X 0.8032,
- X 0.7884,
- X 0.7730,
- X 0.7572,
- X 0.7410,
- X 0.7243,
- X 0.7071,
- X 0.6896,
- X 0.6716,
- X 0.6532,
- X 0.6344,
- X 0.6153,
- X 0.5957,
- X 0.5758,
- X 0.5556,
- X 0.5350,
- X 0.5141,
- X 0.4929,
- X 0.4714,
- X 0.4496,
- X 0.4276,
- X 0.4053,
- X 0.3827,
- X 0.3599,
- X 0.3369,
- X 0.3137,
- X 0.2903,
- X 0.2667,
- X 0.2430,
- X 0.2191,
- X 0.1951,
- X 0.1710,
- X 0.1468,
- X 0.1225,
- X 0.0981,
- X 0.0736,
- X 0.0491,
- X 0.0246,
- X 0.0000,
- X -0.0245,
- X -0.0490,
- X -0.0735,
- X -0.0980,
- X -0.1224,
- X -0.1467,
- X -0.1709,
- X -0.1950,
- X -0.2190,
- X -0.2429,
- X -0.2667,
- X -0.2902,
- X -0.3136,
- X -0.3368,
- X -0.3598,
- X -0.3826,
- X -0.4052,
- X -0.4275,
- X -0.4496,
- X -0.4713,
- X -0.4928,
- X -0.5140,
- X -0.5349,
- X -0.5555,
- X -0.5758,
- X -0.5956,
- X -0.6152,
- X -0.6343,
- X -0.6531,
- X -0.6715,
- X -0.6895,
- X -0.7071,
- X -0.7242,
- X -0.7409,
- X -0.7572,
- X -0.7730,
- X -0.7883,
- X -0.8032,
- X -0.8175,
- X -0.8314,
- X -0.8448,
- X -0.8577,
- X -0.8700,
- X -0.8819,
- X -0.8932,
- X -0.9040,
- X -0.9142,
- X -0.9238,
- X -0.9330,
- X -0.9415,
- X -0.9495,
- X -0.9569,
- X -0.9638,
- X -0.9700,
- X -0.9757,
- X -0.9808,
- X -0.9853,
- X -0.9892,
- X -0.9925,
- X -0.9952,
- X -0.9973,
- X -0.9988,
- X -0.9997
- X};
- Xdouble Cos[] = {
- X 0.0000,
- X 0.0245,
- X 0.0491,
- X 0.0736,
- X 0.0980,
- X 0.1224,
- X 0.1467,
- X 0.1710,
- X 0.1951,
- X 0.2191,
- X 0.2430,
- X 0.2667,
- X 0.2903,
- X 0.3137,
- X 0.3369,
- X 0.3599,
- X 0.3827,
- X 0.4052,
- X 0.4275,
- X 0.4496,
- X 0.4714,
- X 0.4929,
- X 0.5141,
- X 0.5350,
- X 0.5556,
- X 0.5758,
- X 0.5957,
- X 0.6152,
- X 0.6344,
- X 0.6532,
- X 0.6715,
- X 0.6895,
- X 0.7071,
- X 0.7242,
- X 0.7409,
- X 0.7572,
- X 0.7730,
- X 0.7883,
- X 0.8032,
- X 0.8176,
- X 0.8315,
- X 0.8448,
- X 0.8577,
- X 0.8701,
- X 0.8819,
- X 0.8932,
- X 0.9040,
- X 0.9142,
- X 0.9239,
- X 0.9330,
- X 0.9415,
- X 0.9495,
- X 0.9569,
- X 0.9638,
- X 0.9700,
- X 0.9757,
- X 0.9808,
- X 0.9853,
- X 0.9892,
- X 0.9925,
- X 0.9952,
- X 0.9973,
- X 0.9988,
- X 0.9997,
- X 1.0000,
- X 0.9997,
- X 0.9988,
- X 0.9973,
- X 0.9952,
- X 0.9925,
- X 0.9892,
- X 0.9853,
- X 0.9808,
- X 0.9757,
- X 0.9700,
- X 0.9638,
- X 0.9570,
- X 0.9495,
- X 0.9416,
- X 0.9330,
- X 0.9239,
- X 0.9142,
- X 0.9040,
- X 0.8933,
- X 0.8819,
- X 0.8701,
- X 0.8578,
- X 0.8449,
- X 0.8315,
- X 0.8176,
- X 0.8032,
- X 0.7884,
- X 0.7731,
- X 0.7573,
- X 0.7410,
- X 0.7243,
- X 0.7072,
- X 0.6896,
- X 0.6716,
- X 0.6532,
- X 0.6344,
- X 0.6153,
- X 0.5958,
- X 0.5759,
- X 0.5556,
- X 0.5351,
- X 0.5142,
- X 0.4930,
- X 0.4715,
- X 0.4497,
- X 0.4276,
- X 0.4053,
- X 0.3828,
- X 0.3600,
- X 0.3370,
- X 0.3138,
- X 0.2904,
- X 0.2668,
- X 0.2431,
- X 0.2192,
- X 0.1952,
- X 0.1710,
- X 0.1468,
- X 0.1225,
- X 0.0981,
- X 0.0737,
- X 0.0492,
- X 0.0246,
- X 0.0001,
- X -0.0244,
- X -0.0490,
- X -0.0735,
- X -0.0979,
- X -0.1223,
- X -0.1466,
- X -0.1709,
- X -0.1950,
- X -0.2190,
- X -0.2429,
- X -0.2666,
- X -0.2902,
- X -0.3136,
- X -0.3368,
- X -0.3598,
- X -0.3826,
- X -0.4051,
- X -0.4275,
- X -0.4495,
- X -0.4713,
- X -0.4928,
- X -0.5140,
- X -0.5349,
- X -0.5555,
- X -0.5757,
- X -0.5956,
- X -0.6151,
- X -0.6343,
- X -0.6531,
- X -0.6715,
- X -0.6895,
- X -0.7070,
- X -0.7242,
- X -0.7409,
- X -0.7571,
- X -0.7729,
- X -0.7883,
- X -0.8031,
- X -0.8175,
- X -0.8314,
- X -0.8448,
- X -0.8577,
- X -0.8700,
- X -0.8819,
- X -0.8932,
- X -0.9039,
- X -0.9142,
- X -0.9238,
- X -0.9329,
- X -0.9415,
- X -0.9495,
- X -0.9569,
- X -0.9637,
- X -0.9700,
- X -0.9757,
- X -0.9808,
- X -0.9853,
- X -0.9892,
- X -0.9925,
- X -0.9952,
- X -0.9973,
- X -0.9988,
- X -0.9997,
- X -1.0000,
- X -0.9997,
- X -0.9988,
- X -0.9973,
- X -0.9952,
- X -0.9925,
- X -0.9892,
- X -0.9853,
- X -0.9808,
- X -0.9757,
- X -0.9701,
- X -0.9638,
- X -0.9570,
- X -0.9496,
- X -0.9416,
- X -0.9330,
- X -0.9239,
- X -0.9143,
- X -0.9041,
- X -0.8933,
- X -0.8820,
- X -0.8702,
- X -0.8578,
- X -0.8449,
- X -0.8316,
- X -0.8177,
- X -0.8033,
- X -0.7884,
- X -0.7731,
- X -0.7573,
- X -0.7411,
- X -0.7244,
- X -0.7072,
- X -0.6897,
- X -0.6717,
- X -0.6533,
- X -0.6345,
- X -0.6154,
- X -0.5958,
- X -0.5759,
- X -0.5557,
- X -0.5351,
- X -0.5142,
- X -0.4930,
- X -0.4715,
- X -0.4498,
- X -0.4277,
- X -0.4054,
- X -0.3828,
- X -0.3601,
- X -0.3371,
- X -0.3138,
- X -0.2905,
- X -0.2669,
- X -0.2432,
- X -0.2193,
- X -0.1953,
- X -0.1711,
- X -0.1469,
- X -0.1226,
- X -0.0982,
- X -0.0737,
- X -0.0493,
- X -0.0247
- X};
- END_OF_sintab.c
- if test 6925 -ne `wc -c <sintab.c`; then
- echo shar: \"sintab.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f smessage.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"smessage.c\"
- else
- echo shar: Extracting \"smessage.c\" \(5214 characters\)
- sed "s/^X//" >smessage.c <<'END_OF_smessage.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include <math.h>
- X#include <signal.h>
- X#include <ctype.h>
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- X#define ADDRLEN 10
- X
- Xstatic int lcount;
- Xstatic char buf[80];
- Xstatic char addr;
- Xstatic char addrmesg[ADDRLEN];
- X
- Xsmessage(ichar)
- Xchar ichar;
- X{
- X register int i;
- X
- X if (watch) {
- X warning("cannot send messages from watch");
- X return;
- X }
- X if (messpend == 0) {
- X messpend = 1;
- X if (mdisplayed) {
- X XPixSet(messagew, 5, 5, dfontinfo->width * lastcount,
- X dfontinfo->height, backColor);
- X mdisplayed = 0;
- X }
- X /* Put the proper recipient in the window */
- X if (getaddr(ichar) < 0) {
- X /* print error message */
- X messpend = 0;
- X return;
- X }
- X XText(messagew, 5 + dfontinfo->width, 5,
- X addrmesg, ADDRLEN, dfont, textColor, backColor);
- X lcount = ADDRLEN;
- X return;
- X }
- X switch (ichar) {
- X case '\b':
- X case '\177':
- X if (--lcount < ADDRLEN) {
- X lcount = ADDRLEN;
- X break;
- X }
- X XPixSet(messagew, 5 + dfontinfo->width * lcount, 5,
- X dfontinfo->width, dfontinfo->height, backColor);
- X break;
- X case '\027':
- X i = 0;
- X /* back up over blanks */
- X while (--lcount >= ADDRLEN && isspace(buf[lcount - ADDRLEN]))
- X i++;
- X lcount++;
- X /* back up over non-blanks */
- X while (--lcount >= ADDRLEN && !isspace(buf[lcount - ADDRLEN]))
- X i++;
- X lcount++;
- X
- X if (i > 0)
- X XPixSet(messagew, 5 + dfontinfo->width * lcount, 5,
- X dfontinfo->width * i, dfontinfo->height, backColor);
- X break;
- X case '\025':
- X case '\030':
- X if (lcount > ADDRLEN)
- X XPixSet(messagew, 5 + dfontinfo->width * ADDRLEN, 5,
- X dfontinfo->width * (lcount - ADDRLEN),
- X dfontinfo->height, backColor);
- X lcount = ADDRLEN;
- X break;
- X case '\033':
- X XPixSet(messagew, 5, 5, dfontinfo->width * lcount,
- X dfontinfo->height, backColor);
- X mdisplayed = 0;
- X messpend = 0;
- X break;
- X case '\r':
- X buf[lcount - ADDRLEN] = 0;
- X messpend = 0;
- X switch (addr) {
- X case 'A':
- X pmessage(buf, 0, MALL, addrmesg);
- X break;
- X case 'F':
- X pmessage(buf, FED, MTEAM, addrmesg);
- X break;
- X case 'R':
- X case 'r':
- X pmessage(buf, ROM, MTEAM, addrmesg);
- X break;
- X case 'K':
- X case 'k':
- X pmessage(buf, KLI, MTEAM, addrmesg);
- X break;
- X case 'O':
- X case 'o':
- X pmessage(buf, ORI, MTEAM, addrmesg);
- X break;
- X case '0':
- X case '1':
- X case '2':
- X case '3':
- X case '4':
- X case '5':
- X case '6':
- X case '7':
- X case '8':
- X case '9':
- X pmessage(buf, addr - '0', MINDIV, addrmesg);
- X break;
- X case 'a':
- X case 'b':
- X case 'c':
- X case 'd':
- X case 'e':
- X case 'f':
- X pmessage(buf, addr - 'a' - 10, MINDIV, addrmesg);
- X break;
- X default:
- X warning("Not legal recipient");
- X }
- X XPixSet(messagew, 5, 5, dfontinfo->width * lcount,
- X dfontinfo->height, backColor);
- X mdisplayed = 0;
- X lcount = 0;
- X break;
- X default:
- X if (lcount == 80) {
- X XFeep(0);
- X break;
- X }
- X if (iscntrl(ichar))
- X break;
- X XText(messagew, 5 + dfontinfo->width * lcount, 5,
- X &ichar, 1, dfont, textColor, backColor);
- X buf[(lcount++) - ADDRLEN] = ichar;
- X break;
- X }
- X}
- X
- Xpmessage(str, recip, group, address)
- Xchar *str;
- Xint recip;
- Xint group;
- Xchar *address;
- X{
- X struct message *cur;
- X if (++(mctl->mc_current) >= MAXMESSAGE)
- X mctl->mc_current = 0;
- X cur = &messages[mctl->mc_current];
- X cur->m_no = mctl->mc_current;
- X cur->m_flags = group;
- X cur->m_time = 0;
- X cur->m_recpt = recip;
- X (void) sprintf(cur->m_data, "%-9s %s", address, str);
- X cur->m_flags |= MVALID;
- X}
- X
- Xgetaddr(who)
- Xchar who;
- X{
- X addr = who;
- X (void) sprintf(addrmesg, " %c%x->", teamlet[me->p_team], me->p_no);
- X switch (who) {
- X case 'A':
- X (void) sprintf(&addrmesg[5], "ALL");
- X break;
- X case 'F':
- X (void) sprintf(&addrmesg[5], "FED");
- X break;
- X case 'R':
- X case 'r':
- X (void) sprintf(&addrmesg[5], "ROM");
- X break;
- X case 'K':
- X case 'k':
- X (void) sprintf(&addrmesg[5], "KLI");
- X break;
- X case 'O':
- X case 'o':
- X (void) sprintf(&addrmesg[5], "ORI");
- X break;
- X case '0':
- X case '1':
- X case '2':
- X case '3':
- X case '4':
- X case '5':
- X case '6':
- X case '7':
- X case '8':
- X case '9':
- X if (isAlive(&players[who - '0'])) {
- X (void) sprintf(&addrmesg[5], "%c%x ",
- X teamlet[players[who - '0'].p_team], who - '0');
- X }
- X else {
- X warning("Player is not in game");
- X return(-1);
- X }
- X break;
- X case 'a':
- X case 'b':
- X case 'c':
- X case 'd':
- X case 'e':
- X case 'f':
- X if (isAlive(&players[who - 'a' + 10])) {
- X (void) sprintf(&addrmesg[5], "%c%x ",
- X teamlet[players[who - 'a' + 10].p_team], who - 'a' + 10);
- X }
- X else {
- X warning("Player is not in game");
- X return(-1);
- X }
- X break;
- X default:
- X warning("Not legal recipient");
- X return(-1);
- X }
- X return(0);
- X}
- END_OF_smessage.c
- if test 5214 -ne `wc -c <smessage.c`; then
- echo shar: \"smessage.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f stats.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"stats.c\"
- else
- echo shar: Extracting \"stats.c\" \(5532 characters\)
- sed "s/^X//" >stats.c <<'END_OF_stats.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- X#define MIN(a,b) (((a) < (b)) ? (a) : (b))
- X#define MAX(a,b) (((a) > (b)) ? (a) : (b))
- X
- X#define BX_OFF() ((textWidth + 1) * dfontinfo->width + S_IBORDER)
- X#define BY_OFF(line) ((line) * (dfontinfo->height + S_IBORDER) + S_IBORDER)
- X#define TX_OFF(len) ((textWidth - len) * dfontinfo->width + S_IBORDER)
- X#define TY_OFF(line) BY_OFF(line)
- X
- X#define STAT_WIDTH 160
- X#define STAT_HEIGHT BY_OFF(NUM_SLIDERS)
- X#define STAT_BORDER 2
- X#define S_IBORDER 5
- X#define STAT_X 422
- X#define STAT_Y 13
- X
- X#define SL_WID \
- X (STAT_WIDTH - 2 * S_IBORDER - (textWidth + 1) * dfontinfo->width)
- X#define SL_HEI (dfontinfo->height)
- X
- X#define NUM_ELS(a) (sizeof (a) / sizeof (*(a)))
- X#define NUM_SLIDERS NUM_ELS(sliders)
- X
- Xtypedef struct slider {
- X char *label;
- X int min, max;
- X int low_red, high_red;
- X int label_length;
- X int diff;
- X} SLIDER;
- X
- Xtypedef struct record {
- X short *data;
- X short last_value;
- X} RECORD;
- X
- Xstatic SLIDER sliders[] = {
- X { "Shields", 0, 100, 20, 100 },
- X { "Damage", 0, 100, 0, 0 },
- X { "Fuel", 0, 10000, 1000, 10000 },
- X { "Warp", 0, 9, 0, 9 },
- X { "Weapon Temp", 0, 1200, 0, 1000 },
- X { "Engine Temp", 0, 1200, 0, 1000 },
- X};
- X
- Xstatic XAssocTable *table;
- Xstatic int textWidth = 0;
- Xstatic int statX = STAT_X, statY = STAT_Y;
- X
- XinitStats(prog)
- X char *prog;
- X{
- X int i, dummy;
- X char *str;
- X
- X if ((str = XGetDefault(prog, "stats.geometry")) != NULL)
- X XParseGeometry(str, &statX, &statY, &dummy, &dummy);
- X table = (XAssocTable *) XCreateAssocTable(8);
- X for (i = 0; i < NUM_SLIDERS; i++) {
- X sliders[i].label_length = strlen(sliders[i].label);
- X textWidth = MAX(textWidth, sliders[i].label_length);
- X sliders[i].diff = sliders[i].max - sliders[i].min;
- X }
- X}
- X
- XWindow
- XopenStats(p)
- X struct player *p;
- X{
- X Window w;
- X RECORD *rp;
- X extern Cursor crosshair;
- X char *calloc();
- X
- X w = XCreateWindow(RootWindow, statX, statY, STAT_WIDTH, STAT_HEIGHT,
- X STAT_BORDER, foreTile, backTile);
- X XDefineCursor(w, crosshair);
- X rp = (RECORD *) calloc(NUM_SLIDERS, sizeof (RECORD));
- X rp[0].data = &(p->p_shield);
- X rp[1].data = &(p->p_damage);
- X rp[2].data = &(p->p_fuel);
- X rp[3].data = &(p->p_speed);
- X rp[4].data = &(p->p_wtemp);
- X rp[5].data = &(p->p_etemp);
- X XMakeAssoc(table, w, rp);
- X XSelectInput(w, ExposeWindow|ExposeRegion);
- X XMapWindow(w);
- X return (w);
- X}
- X
- XredrawStats(w)
- X Window w;
- X{
- X int i;
- X RECORD *rp;
- X
- X rp = (RECORD *) XLookUpAssoc(table, w);
- X if (rp == NULL) {
- X fputs("You gave redrawStats a bum window\n", stderr);
- X return;
- X }
- X XClear(w);
- X for (i = 0; i < NUM_SLIDERS; i++) {
- X rp[i].last_value = 0;
- X XText(w, TX_OFF(sliders[i].label_length), TY_OFF(i),
- X sliders[i].label, sliders[i].label_length, dfont,
- X textColor, backColor);
- X box(w, 0, BX_OFF() - 1, BY_OFF(i) - 1, SL_WID+2, SL_HEI+2,
- X borderColor, GXcopy, AllPlanes);
- X }
- X}
- X
- XcloseStats(w)
- X Window w;
- X{
- X WindowInfo wi;
- X
- X XDeleteAssoc(table, w);
- X if (XQueryWindow(w, &wi) != 0) {
- X statX = wi.x;
- X statY = wi.y;
- X }
- X XDestroyWindow(w);
- X}
- X
- XupdateStats(w)
- X Window w;
- X{
- X int i, value, diff, color, old_x, new_x, wid;
- X RECORD *rp, *r;
- X SLIDER *s;
- X
- X rp = (RECORD *) XLookUpAssoc(table, w);
- X for (i = 0; i < NUM_SLIDERS; i++) {
- X r = &rp[i];
- X s = &sliders[i];
- X value = *(r->data);
- X if (value < s->min)
- X value = s->min;
- X else if (value > s->max)
- X value = s->max;
- X if (value == r->last_value)
- X continue;
- X diff = value - r->last_value;
- X if (diff < 0)
- X color = backColor;
- X else {
- X if (value < s->low_red)
- X color = warningColor;
- X else if (value > s->high_red) {
- X color = warningColor;
- X if (r->last_value <= s->high_red)
- X r->last_value = 0;
- X } else {
- X color = myColor;
- X if (r->last_value < s->low_red)
- X r->last_value = 0;
- X }
- X }
- X old_x = r->last_value * SL_WID / s->diff;
- X new_x = value * SL_WID / s->diff;
- X wid = new_x - old_x;
- X /*
- X if (wid > 0)
- X wid++;
- X else if (wid < 0)
- X wid--;
- X */
- X box(w, 1, BX_OFF() + old_x, BY_OFF(i), wid,
- X SL_HEI, color, GXcopy, AllPlanes);
- X if (diff < 0) {
- X if (r->last_value >= s->low_red && value < s->low_red)
- X box(w, 1, BX_OFF(), BY_OFF(i), new_x, SL_HEI,
- X warningColor, GXcopy, AllPlanes);
- X else if (r->last_value > s->high_red &&
- X value <= s->high_red)
- X box(w, 1, BX_OFF(), BY_OFF(i), new_x, SL_HEI,
- X myColor, GXcopy, AllPlanes);
- X }
- X r->last_value = value;
- X }
- X}
- X
- X
- X
- Xbox(w, filled, x, y, wid, hei, pixel, func, planes)
- X Window w;
- X{
- X Vertex vertex[5];
- X
- X if (wid == 0 || hei == 0)
- X return;
- X
- X if (filled) {
- X int minX, minY;
- X
- X minX = MIN(x, x + wid);
- X wid = ABS(wid);
- X minY = MIN(y, y + hei);
- X hei = ABS(hei);
- X XPixFill(w, minX, minY, wid + 1, hei + 1, pixel, 0,
- X func, planes);
- X return;
- X }
- X
- X vertex[0].x = x;
- X vertex[0].y = y;
- X vertex[0].flags = VertexStartClosed;
- X
- X vertex[1].x = x + wid;
- X vertex[1].y = y;
- X vertex[1].flags = 0;
- X
- X vertex[2].x = x + wid;
- X vertex[2].y = y + hei;
- X vertex[2].flags = 0;
- X
- X vertex[3].x = x;
- X vertex[3].y = y + hei;
- X vertex[3].flags = 0;
- X
- X vertex[4].x = x;
- X vertex[4].y = y;
- X vertex[4].flags = VertexEndClosed;
- X
- X XDraw(w, vertex, 5, 1, 1, pixel, func, planes);
- X}
- END_OF_stats.c
- if test 5532 -ne `wc -c <stats.c`; then
- echo shar: \"stats.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f struct.h -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"struct.h\"
- else
- echo shar: Extracting \"struct.h\" \(6570 characters\)
- sed "s/^X//" >struct.h <<'END_OF_struct.h'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- Xstruct status {
- X int active;
- X};
- X
- X#define PFREE 0
- X#define POUTFIT 1
- X#define PALIVE 2
- X#define PEXPLODE 3
- X#define PDEAD 4
- X
- X#define PFSHIELD 0x0001
- X#define PFREPAIR 0x0002
- X#define PFBOMB 0x0004
- X#define PFORBIT 0x0008
- X#define PFCLOAK 0x0010
- X#define PFWEP 0x0020
- X#define PFENG 0x0040
- X#define PFROBOT 0x0080
- X#define PFBEAMUP 0x0100
- X#define PFBEAMDOWN 0x0200
- X#define PFSELFDEST 0x0400
- X#define PFGREEN 0x0800
- X#define PFYELLOW 0x1000
- X#define PFRED 0x2000
- X#define PFPLOCK 0x4000 /* Locked on a player */
- X#define PFPLLOCK 0x8000 /* Locked on a planet */
- X#define PFCOPILOT 0x10000 /* Allow copilots */
- X#define PFWAR 0x20000 /* computer reprogramming for war */
- X#define PFPRACTR 0x40000 /* practice type robot (no kills) */
- X
- X#define KQUIT 0x01 /* Player quit */
- X#define KTORP 0x02 /* killed by torp */
- X#define KPHASER 0x03 /* killed by phaser */
- X#define KPLANET 0x04 /* killed by planet */
- X#define KSHIP 0x05 /* killed by other ship */
- X#define KDAEMON 0x06 /* killed by dying daemon */
- X#define KWINNER 0x07 /* killed by a winner */
- X#define KGHOST 0x08 /* killed because a ghost */
- X
- Xstruct ship {
- X int s_turns;
- X short s_accs;
- X short s_torpdamage;
- X short s_phaserdamage;
- X short s_torpspeed;
- X short s_maxspeed;
- X short s_repair;
- X short s_maxfuel;
- X short s_torpcost;
- X short s_phasercost;
- X short s_detcost;
- X short s_warpcost;
- X short s_cloakcost;
- X short s_recharge;
- X int s_accint;
- X int s_decint;
- X short s_maxarmies;
- X};
- X
- Xstruct stats {
- X int st_time; /* real time in game */
- X int st_cpu; /* cpu time in game */
- X double st_kills; /* how many kills */
- X int st_losses; /* times killed */
- X double st_maxkills; /* times killed */
- X int st_entries; /* times in game */
- X int st_conqs; /* times galaxy taken over */
- X int st_coups; /* retaken home planet */
- X int st_torps; /* torps launched */
- X int st_phasers; /* phasers fired */
- X int st_armsbomb; /* armies bombed */
- X int st_armsship; /* ship board armies killed */
- X int st_planets; /* planets conquered */
- X int st_genocides; /* races genocided */
- X};
- X
- Xstruct player {
- X int p_no;
- X int p_updates; /* Number of updates ship has survived */
- X int p_status; /* Player status */
- X unsigned int p_flags; /* Player flags */
- X char p_name[16];
- X char p_login[16];
- X char p_monitor[16]; /* Monitor being played on */
- X char p_mapchars[2]; /* Cache for map window image */
- X struct ship p_ship; /* Personal ship statistics */
- X int p_x;
- X int p_y;
- X unsigned char p_dir; /* Real direction */
- X unsigned char p_desdir; /* desired direction */
- X int p_subdir; /* fraction direction change */
- X short p_speed; /* Real speed */
- X short p_desspeed; /* Desired speed */
- X int p_subspeed; /* Fractional speed */
- X short p_team; /* Team I'm on */
- X short p_damage; /* Current damage */
- X int p_subdamage; /* Fractional damage repair */
- X short p_shield; /* Current shield power */
- X int p_subshield; /* Fractional shield recharge */
- X short p_ntorp; /* Number of torps flying */
- X char p_hostile; /* Who my torps will hurt */
- X char p_swar; /* Who am I at sticky war with */
- X float p_kills; /* Enemies killed */
- X short p_planet; /* Planet orbiting or locked onto */
- X short p_playerl; /* Player locked onto */
- X short p_armies;
- X short p_fuel;
- X short p_explode; /* Keeps track of final explosion */
- X short p_etemp;
- X short p_etime;
- X short p_wtemp;
- X short p_wtime;
- X short p_whydead; /* Tells you why you died */
- X short p_whodead; /* Tells you who killed you */
- X struct stats p_stats; /* player statistics */
- X int p_ghostbuster;
- X};
- X
- X/* Torpedo states */
- X
- X#define TFREE 0
- X#define TMOVE 1
- X#define TEXPLODE 2
- X#define TDET 3
- X#define TOFF 4
- X#define TSTRAIGHT 5 /* Non-wobbling torp */
- X
- Xstruct torp {
- X int t_no;
- X int t_status; /* State information */
- X int t_owner;
- X int t_x;
- X int t_y;
- X unsigned char t_dir; /* direction */
- X int t_damage; /* damage for direct hit */
- X int t_speed; /* Moving speed */
- X int t_fuse; /* Life left in current state */
- X char t_war; /* enemies */
- X char t_team; /* launching team */
- X};
- X
- X#define PHFREE 0x00
- X#define PHHIT 0x01
- X#define PHMISS 0x02
- X
- Xstruct phaser {
- X int ph_status; /* What it's up to */
- X unsigned char ph_dir; /* direction */
- X int ph_target; /* Who's being hit (for drawing) */
- X int ph_fuse; /* Life left for drawing */
- X int ph_damage; /* Damage inflicted on victim */
- X};
- X
- X/* An important note concerning planets: The game assumes that
- X the planets are in a 'known' order. Ten planets per team,
- X the first being the home planet.
- X*/
- X
- X/* the lower bits represent the original owning team */
- X#define PLREPAIR 0x010
- X#define PLFUEL 0x020
- X#define PLREDRAW 0x040 /* Player close for redraw */
- X#define PLHOME 0x080 /* home planet for a given team */
- X#define PLCOUP 0x100 /* Coup has occured */
- X
- Xstruct planet {
- X int pl_no;
- X int pl_flags; /* State information */
- X int pl_owner;
- X int pl_x;
- X int pl_y;
- X char pl_name[16];
- X int pl_namelen; /* Cuts back on strlen's */
- X int pl_armies;
- X int pl_info; /* Teams which have info on planets */
- X int pl_deadtime; /* Time before planet will support life */
- X int pl_couptime; /* Time before coup may take place */
- X};
- X
- X#define MVALID 0x01
- X#define MINDIV 0x02
- X#define MTEAM 0x04
- X#define MALL 0x08
- X
- Xstruct message {
- X int m_no;
- X int m_flags;
- X int m_time;
- X int m_recpt;
- X char m_from[3];
- X char m_to[3];
- X char m_data[80];
- X};
- X
- X/* message control structure */
- X
- Xstruct mctl {
- X int mc_current;
- X};
- X
- X/* This is a structure used for objects returned by mouse pointing */
- X
- X#define PLANETTYPE 0x1
- X#define PLAYERTYPE 0x2
- X
- Xstruct obtype {
- X int o_type;
- X int o_num;
- X};
- X
- Xstruct memory {
- X struct player players[MAXPLAYER];
- X struct torp torps[MAXPLAYER * MAXTORP];
- X struct status status[1];
- X struct planet planets[MAXPLANETS];
- X struct phaser phasers[MAXPLAYER];
- X struct mctl mctl[1];
- X struct message messages[MAXMESSAGE];
- X};
- END_OF_struct.h
- if test 6570 -ne `wc -c <struct.h`; then
- echo shar: \"struct.h\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- if test -f war.c -a "${1}" != "-c" ; then
- echo shar: Will not over-write existing file \"war.c\"
- else
- echo shar: Extracting \"war.c\" \(4407 characters\)
- sed "s/^X//" >war.c <<'END_OF_war.c'
- X
- X/*
- X
- X Copyright (c) 1986 Chris Guthrie
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation. No representations are made about the
- Xsuitability of this software for any purpose. It is
- Xprovided "as is" without express or implied warranty.
- X
- X*/
- X
- X#include <X/Xlib.h>
- X#include <stdio.h>
- X#include <math.h>
- X#include <signal.h>
- X#include "defs.h"
- X#include "struct.h"
- X#include "data.h"
- X
- X#define WINSIDE 500
- X
- Xstatic int newhostile;
- Xstatic int reprogram;
- X
- X/* Set up the war window and map it */
- Xstatic char *feds = "FED - ";
- Xstatic char *roms = "ROM - ";
- Xstatic char *klis = "KLI - ";
- Xstatic char *oris = "ORI - ";
- Xstatic char *gos = " Re-program";
- Xstatic char *exs = " Exit - no change";
- Xstatic char *peaces = "Peace";
- Xstatic char *hostiles = "Hostile";
- Xstatic char *wars = "War";
- X
- Xwarwindow()
- X{
- X XMapWindow(war);
- X newhostile = me->p_hostile;
- X reprogram = 0;
- X warrefresh();
- X}
- X
- Xwarrefresh()
- X{
- X fillwin(warf, feds, newhostile, me->p_swar, FED);
- X fillwin(warr, roms, newhostile, me->p_swar, ROM);
- X fillwin(wark, klis, newhostile, me->p_swar, KLI);
- X fillwin(waro, oris, newhostile, me->p_swar, ORI);
- X XText(wargo, 0, dfontinfo->height / 2, gos, strlen(gos), dfont,
- X textColor, backColor);
- X XText(warno, 0, dfontinfo->height / 2, exs, strlen(exs), dfont,
- X textColor, backColor);
- X}
- X
- Xfillwin(win, string, hostile, warbits, team)
- XWindow win;
- Xchar *string;
- Xint hostile, warbits;
- Xint team;
- X{
- X char buf[80];
- X XPixSet(win, 0, dfontinfo->height / 2, dfontinfo->width * 20,
- X dfontinfo->height, backColor);
- X if (team & warbits) {
- X (void) sprintf(buf, " %s%s", string, wars);
- X XText(win, 0, dfontinfo->height / 2, buf, strlen(buf), dfont,
- X rColor, backColor);
- X }
- X else if (team & hostile) {
- X (void) sprintf(buf, " %s%s", string, hostiles);
- X XText(win, 0, dfontinfo->height / 2, buf, strlen(buf), dfont,
- X yColor, backColor);
- X }
- X else {
- X (void) sprintf(buf, " %s%s", string, peaces);
- X XText(win, 0, dfontinfo->height / 2, buf, strlen(buf), dfont,
- X gColor, backColor);
- X }
- X}
- X
- Xwaraction(data)
- XXKeyOrButtonEvent *data;
- X{
- X int changes;
- X
- X if ((data->window != warno) && (watch)) {
- X warning("can't modify war settings from watch");
- X return;
- X }
- X if (data->window == warf) {
- X if (me->p_swar & FED) {
- X warning("You are already at war with the Federation");
- X XFeep(0);
- X }
- X else {
- X newhostile ^= FED;
- X }
- X }
- X if (data->window == warr) {
- X if (me->p_swar & ROM) {
- X warning("You are already at war with the Romulans");
- X XFeep(0);
- X }
- X else {
- X newhostile ^= ROM;
- X }
- X }
- X if (data->window == wark) {
- X if (me->p_swar & KLI) {
- X warning("You are already at war with the Klingons");
- X XFeep(0);
- X }
- X else {
- X newhostile ^= KLI;
- X }
- X }
- X if (data->window == waro) {
- X if (me->p_swar & ORI) {
- X warning("You are already at war with the Orions");
- X XFeep(0);
- X }
- X else {
- X newhostile ^= ORI;
- X }
- X }
- X warrefresh();
- X
- X if (data->window == wargo) {
- X changes = me->p_hostile ^ newhostile;
- X if (changes & FED) {
- X sendwarn("Federation", newhostile & FED, FED);
- X }
- X if (changes & ROM) {
- X sendwarn("Romulans", newhostile & ROM, ROM);
- X }
- X if (changes & KLI) {
- X sendwarn("Klingons", newhostile & KLI, KLI);
- X }
- X if (changes & ORI) {
- X sendwarn("Orions", newhostile & ORI, ORI);
- X }
- X me->p_hostile = newhostile;
- X if (reprogram) {
- X delay = me->p_updates + 100;
- X me->p_flags |= PFWAR; /* stop copilots, mostly */
- X warning("Pausing ten seconds to re-program battle computers.");
- X }
- X XUnmapWindow(war);
- X return;
- X }
- X
- X if (data->window == warno) {
- X XUnmapWindow(war);
- X return;
- X }
- X}
- X
- Xsendwarn(string, atwar, team)
- Xchar *string;
- Xint atwar;
- Xint team;
- X{
- X char buf[BUFSIZ];
- X char addrbuf[10];
- X
- X if (atwar) {
- X (void) sprintf(buf, "%s (%c%x) declaring war on the %s",
- X me->p_name,
- X teamlet[me->p_team],
- X me->p_no,
- X string);
- X reprogram = 1;
- X }
- X else {
- X (void) sprintf(buf, "%s (%c%x) declaring peace with the %s",
- X me->p_name,
- X teamlet[me->p_team],
- X me->p_no,
- X string);
- X }
- X
- X (void) sprintf(addrbuf, " %c%x->%-3s",
- X teamlet[me->p_team],
- X me->p_no,
- X teamshort[team]);
- X pmessage(buf, team, MTEAM, addrbuf);
- X}
- END_OF_war.c
- if test 4407 -ne `wc -c <war.c`; then
- echo shar: \"war.c\" unpacked with wrong size!
- fi
- # end of overwriting check
- fi
- echo shar: End of archive 4 \(of 6\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 6 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 6 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-
- $